package scau.erps.view.decision.table;

import java.util.Iterator;
import java.util.List;

import javax.swing.table.AbstractTableModel;

import scau.erps.entity.Loan;

public class LoanListModel extends AbstractTableModel {
	private static final long serialVersionUID = 1L;	
		private String[] title = {"贷款单号","贷款类型","金额","申请时间","还款时间","利息"};
		private Object[][] data= null;
		public LoanListModel(List<Loan> list){		
			data =  new Object[list.size()][title.length];
			Iterator<Loan> iter = list.iterator();
			for (int i = 0; i < list.size(); i++) {
				Loan loan = iter.next();			
				data[i][0] = loan.getLoanNo();	
				data[i][1] = loan.getLoanType();
				data[i][2] = loan.getAmount();
				data[i][3] = loan.getBeginTime();
				data[i][4] = loan.getEndTime();
				data[i][5] = loan.getInterest();
			}				
			
	}

	@Override
	public int getRowCount() {
		return this.data.length; //行数
	}

	@Override
	public int getColumnCount() {
		return this.title.length; //列数
	}

	@Override
	public Object getValueAt(int rowIndex, int columnIndex) {
		return  data[rowIndex][columnIndex];  //取表格单元格值
	}
	public String getColumnName(int columnIndex) {
        return title[columnIndex];  //显示标题
    }

}
